/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import java.awt.*;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;

/**
 *
 * @author Benjamin De Clercq, Michiel Vancoillie, Ruben Slabbinck
 */
public class Spel extends JFrame {

    static final int SPELERID1 = 1;
    static final int SPELERID2 = 2;
    // keuze1 = JOptionPane.YES_OPTION of JOptionPane.NO_OPTION om al dan niet tegen de pc te spelen
    private int keuze1;

    public Spel(String title) {
        super(title);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocation(50, 50);
        //setPreferredSize(new Dimension(1100, 830));
        setLayout(new BorderLayout(20,20)/*FlowLayout(FlowLayout.LEFT, 0, 0)*/);
        /*
         *horizontale en vertikale tussenruimte in pixels tussen de verschillende gebieden
         *wordt meegegeven aan de constructor
        */

        Bord bord = new Bord();
        KeuzePaneel keuzePaneelBlauw = new KeuzePaneel(SPELERID1);
        KeuzePaneel keuzePaneelRood = new KeuzePaneel(SPELERID2);
        bord.setKeuzePaneel(keuzePaneelRood, keuzePaneelBlauw);

        JPanel pane2 = new JPanel();
        pane2.setLayout(new BoxLayout(pane2,BoxLayout.PAGE_AXIS));
        pane2.add(Box.createRigidArea(new Dimension(0, 30)));

        keuze1 = JOptionPane.showConfirmDialog(this, "Wilt u tegen de computer spelen?", "Maak een keuze", JOptionPane.YES_NO_OPTION);

        if (keuze1 == JOptionPane.YES_OPTION) {
            JPanel strings = new JPanel();
            strings.setLayout(new BoxLayout(strings,BoxLayout.Y_AXIS));
            JLabel string = new JLabel();
            string.setFont(new Font("Arial",Font.PLAIN,50));
            string.setText("      COMPUTER");
            JLabel string2 = new JLabel();
            string2.setFont(new Font("Arial",Font.PLAIN,20));
            string2.setText("                                   VS");
            strings.add(string);
            strings.add(string2);
            pane2.add(strings);
            bord.fillRandomBoardForPlayer(Bord.COMPUTER, 0, 4);
        } else if (keuze1 == JOptionPane.NO_OPTION) {
            pane2.add(keuzePaneelBlauw);
        }

        pane2.add(Box.createRigidArea(new Dimension(0, 30)));
        pane2.add(keuzePaneelRood);

        JPanel pane3 = new JPanel(new FlowLayout());
        pane3.add(pane2);
        pane3.add(Box.createRigidArea(new Dimension(20,0)));

        add(bord,BorderLayout.CENTER);
        add(pane3,BorderLayout.EAST);
        add(Box.createRigidArea(new Dimension(0, 0)),BorderLayout.WEST);
        add(Box.createRigidArea(new Dimension(0, 0)),BorderLayout.NORTH);
        add(Box.createRigidArea(new Dimension(0, 0)),BorderLayout.SOUTH);

        pack();
        this.setMinimumSize(this.getSize());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        new Spel("Stratego").setVisible(true);

    }

    public static void quit(){
        System.exit(0);
    }

}
